#!/bin/bash
#
#dev:enCEE
#
#vars
DIR=$PWD
sys_scripts_dir=$DIR
#functions
arch_menu()
{
	for(( x = 0; x < 1;))
			do
			case $selection in
				1)
					
				    if [ -e /tmp/f_lang ]
					then
						echo "Settings already exist!"
						echo "Do you wish to continue? [y/n]"
						read exists
						case $exists in
							y) 
								$sys_scripts_dir/arch_lang
								x=1
							;;
							n)
								$sys_scripts_dir/arch_menu
								x=1
							;;
						esac
					else
						touch /tmp/f_lang
						$sys_scripts_dir/arch_lang
					fi
				;;
				2)
					if [ -e /tmp/f_netconf ]
					then
						echo "Settings already exist!"
						echo "Do you wish to continue? [y/n]"
						read exists
						case $exists in
							y) 
								$sys_scripts_dir/arch_netconf
								x=1
							;;
							n)
								$sys_scripts_dir/arch_menu
								x=1
							;;
						esac
					else
					touch /tmp/f_netconf
					$sys_scripts_dir/arch_netconf
					fi
				;;
				3)
					if [ -e /tmp/f_format ]
					then
						echo "Settings already exist!"
						echo "Do you wish to continue? [y/n]"
						read exists
						case $exists in
							y) 
								$sys_scripts_dir/arch_format
								x=1				
							;;
							n)
								$sys_scripts_dir/arch_menu
								x=1
							;;
						esac
					else
					touch /tmp/f_format
					$sys_scripts_dir/arch_format
					fi
				;;
				4) 
					if [ -e /tmp/f_mount ]
					then
						echo "Settings already exist!"
						echo "Do you wish to continue? [y/n]"
						read exists
						case $exists in
							y) 
								$sys_scripts_dir/arch_drives
								x=1
							;;
							n)
								$sys_scripts_dir/arch_menu
								x=1
							;;
						esac
					else
					touch /tmp/f_mount
					$sys_scripts_dir/arch_mount
					fi
				;;
				5)	
					if [ -e /tmp/f_base ]
					then
						echo "Settings already exist!"
						echo "Do you wish to continue? [y/n]"
						read exists
						case $exists in
							y) 
								$sys_scripts_dir/arch_base
								x=1
							;;
							n)
								$sys_scripts_dir/arch_menu
								x=1
							;;
						esac
					else
					touch /tmp/f_base
					$sys_scripts_dir/arch_base
					fi
				;;
				6)
					if [ -e /tmp/f_netconfpost ]
					then
						echo "Settings already exist!"
						echo "Do you wish to continue? [y/n]"
						read exists
						case $exists in
							y) 
								$sys_scripts_dir/arch_postnetconf
								x=1
							;;
							n)
								$sys_scripts_dir/arch_menu
								x=1
							;;
						esac
					else
					touch /tmp/f_netconfpost
					$sys_scripts_dir/arch_netconfpost
					fi
				;;
				7)
					nano /etc/pacman.conf
				;;
				8)
					if [ -e /tmp/f_user ]
					then	
						echo "Settings already exist!"
						echo "Do you wish to continue? [y/n]"
						read exists
						case $exists in
							y) 
								$sys_scripts_dir/arch_user
								x=1
							;;
							n)
								$sys_scripts_dir/arch_menu
								x=1
							;;
						esac
					else
					touch /tmp/f_user
					$sys_scripts_dir/arch_user
					fi
				;;
				9)
					if [ -e /tmp/f_boot ]
					then	
						echo "Settings already exist!"
						echo "Do you wish to continue? [y/n]"
						read exists
						case $exists in
							y) 
								$sys_scripts_dir/arch_boot
								x=1
							;;
							n)
								$sys_scripts_dir/arch_menu
								x=1
							;;
						esac
					else
					touch /tmp/f_boot
					$sys_scripts_dir/arch_boot
					fi
				;;
				10)
					echo "This will end the installation"
					echo "Are you sure you are ready to proceed? [y/n]"
					read proceed
						case $proceed in
							y)
								$sys_scripts_dir/arch_finish
								x=1
							;;
							n)
								$sys_scripts_dir/arch_menu
								x=1
							;;
						esac
				;;
				"Help" | "help" | "H" | "h")
					sys_scripts_dir/arch_help
				;;
				"Quit" | "quit" | "Q" | "q" )
					exit 0
				;;	
				*)
					echo "Invalid Response"
					echo "Please select an option from above"
					read selection
				;;
			esac
		done
}
#
#script
PWD
clear
echo "-------------------------------------------"
echo "-      Welcome to the Arch Installer      -"
echo "-                                         -"
echo "-        For help type 'Help'             -"
echo "-                                         -"
echo "-      Please select an option below      -"
echo "-------------------------------------------"
echo "-                                         -"
echo "-                                         -"
echo "-1) Change the languange                  -"
echo "-2) Establish a Network Connection        -"
echo "-3) Prepare the storage drive             -"
echo "-4) Mount the partitions                  -"
echo "-5) Install the base system               -"
echo "-6) Configure the Network                 -"
echo "-7) Configure pacman                      -"
echo "-8) User Control                          -"
echo "-9) Install a bootloader                 -"
echo "-10) Unmount and reboot                   -"
echo "-                                         -"
echo "-[H]elp -Open Help Document               -"
echo "-[Q]uit -Quit installation                -"
echo "-------------------------------------------"
echo "What is your selection?"
read selection
arch_menu


#end
